package com.base.myproject.client.busi;

import com.extjs.gxt.ui.client.data.ModelData;
/**
 *判断store的行是否能被删除或增加修改的信息类
 *根据某个字段的值与比较的值按照指定的比较规则，返回一个boolean值
 *
 * @author zgw
 *
 */
public class RecordCompareInfo {

	String columnname,comparevalue;
	ModelData modeldata = null;
	int rule;
	public final static int Digital_equals = 1;
	public final static int Digital_More_than = 2;
	public final static int Digital_Less_than = 3;
	public final static int String_equals =4 ;
	public final static int String_More_than = 5;
	public final static int String_Less_than = 6;
	public RecordCompareInfo(String columnname,String comparevalue,int rule)
	{
		this.columnname = columnname ; 
	
		this.comparevalue = comparevalue;
		this.rule = rule;
	}
	
	public ModelData getModeldata() {
		return modeldata;
	}

	public void setModeldata(ModelData modeldata) {
		this.modeldata = modeldata;
	}

	public boolean Compare()
	{
		if(modeldata == null)
			return false;
		boolean b = false;
		switch(rule)
		{
		case String_equals:
			b = modeldata.get(columnname).equals(comparevalue);
			break;
		case String_More_than:
			b = modeldata.get(columnname).toString().compareTo(comparevalue)>0;
			
			break;
			
		case String_Less_than:
			b = modeldata.get(columnname).toString().compareTo(comparevalue)<0;
			
			break;
			default :
				//TODO
				b = false;
		}
		return b;
		
	}
	
	
}
